const express = require("express");
const router = express.Router();
const models = require("../models");
const Op = models.Sequelize.Op; // 模糊查询的时候需要用到

// 查询二课分列表
router.get("/list", async function (req, res, next) {
  const where = {};
  const result = await models.Score.findAndCountAll({
    where: where,
  });
  res.json({
    code: 200,
    msg: "操作成功",
    data: {
      total: result.count,
      data: result.rows,
    },
  });
});

// 修改二课分
router.put("/", async function (req, res, next) {
  const result = await models.Score.findByPk(req.body.id);
  result.update(req.body);
  res.json({
    code: 200,
    msg: "操作成功",
  });
});

module.exports = router;
